import { setCreepStand } from '@/global/move';
import { TaskBase } from '../TaskBase';

export class TaskUpgrade extends TaskBase {
    shouldRun(creep: Creep): boolean {
        // 只要目标还存在且还有能量
        return 'structureType' in this.target
            && this.target.structureType === STRUCTURE_CONTROLLER
            && creep.store.energy > 0;
    }

    _run(creep: Creep) {
        return this.defaultProcess(creep.upgradeController(<StructureController>this.target), () => {
            setCreepStand(creep.name, true);
        });
    }
}